/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.view;

import com.model.Anggota;
import com.model.Perpustakaan;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 *
 * @author tashiba
 */
public class PanelCariAnggota extends JPanel {

//    private JLabel labelPanel;
//        private JLabel labelNim;
//        private JTextField textNim;
    private JLabel labelNama;
    private JTextField textNama;
    private JButton tombolSimpan;
    private JButton tombolBatal;

    public PanelCariAnggota() {

        setLayout(null);

//        labelPanel = new JLabel("Panel Cari Anggota");
//        labelPanel.setBounds(190, 15, 200, 40);
//        add(labelPanel);
//
//            labelNim = new JLabel("Nim");
//            labelNim.setBounds(50, 120, 80, 20);
//            add(labelNim);
//
//            textNim = new JTextField();
//            textNim.setBounds(130, 120, 200, 20);
//            textNim.setBackground(Color.WHITE);
//            add(textNim);

        labelNama = new JLabel("Nama");
        labelNama.setBounds(50, 150, 80, 20);
        add(labelNama);

        textNama = new JTextField();
        textNama.setBounds(130, 150, 150, 20);
//        textNama.setBackground(Color.WHITE);
        add(textNama);

        tombolSimpan = new JButton("CARI");
        tombolSimpan.setBounds(150, 230, 100, 20);
        add(tombolSimpan);
        tombolSimpan.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                tombolSimpanAction();
            }
        });

        tombolBatal = new JButton("BATAL");
        tombolBatal.setBounds(290, 230, 100, 20);
        add(tombolBatal);
        tombolBatal.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                tombolBatalAction();
            }
        });

        setVisible(true);
    }

    public void tombolSimpanAction() {
//            Anggota CP = new Anggota();
        JDialog test = new JDialog();
//            CP.setIdAnggota(textNim.getText());
//            CP.setNama(textNama.getText());
//        Perpustakaan.cariAnggota(textNama.getText());
//        PanelLihatAnggota test = new PanelLihatAnggota(Perpustakaan.DAFTAR_ANGGOTA);
//        testFrame.getContentPane().add(test);
        test.setSize(600, 650);
        test.setVisible(true);
        test.setTitle("Panel Periksa Identitas");
    
    
        ArrayList<Anggota> test1 = Perpustakaan.cariAnggota(textNama.getText());
        for (int i = 0; i < test1.size(); i++) {
            System.out.println("Nama = " + test1.get(i).getNama());

        }
    }

    public void tombolBatalAction() {
        System.exit(0);
    }
    

    public static void main(String[] args) {
        PanelCariAnggota test = new PanelCariAnggota();
    }
}
